package com.banzhi.shop.utils;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;

import com.banzhi.shop.MyApp;
import com.banzhi.shop.activity.NewLoginActivity;

import org.json.JSONObject;

import static com.banzhi.shop.base.BaseActivity.finishAllActivity;

/**
 * Created by HT on 2017/6/5.
 */

public class NoTokenUtils {
    public static void loginOut(Activity activity, JSONObject jsonObject) {
        if ("".equals(jsonObject.optString("code"))) {
            Intent intent = new Intent(activity, NewLoginActivity.class);
            activity.startActivity(intent);
            SharedPreferences.Editor editor = MyApp.loginMessage.edit();
            editor.putString("token", "");
            editor.putString("personNickname", "");
            editor.putString("personAvatar", "");
            editor.putString("personBirth", "");
            editor.putString("personGender", "");
            editor.putString("shopname", "");
            editor.putString("shoplogo", "");
            editor.putString("shopimg", "");
            editor.putString("shopDescription", "");
            editor.putString("recommendName", "");
            editor.apply();
            finishAllActivity();
        }
    }
}
